package com.hxht.cmp.controller;

import com.hxht.cmp.common.enums.ResultCode;
import com.hxht.cmp.common.result.ResultResponse;
import com.hxht.cmp.pojo.SearchCriteria;
import com.hxht.cmp.service.WarnInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 报警信息
 */
@RestController
@RequestMapping("/warn")
public class WarnInfoControl {
    @Autowired
    private WarnInfoService warnInfoService;

    /**
     * 报警信息查询
     *
     * @param searchCriteria
     * @return
     */
    @RequestMapping("/selectWarnInfoList")
    @ResponseBody
    public ResultResponse selectWarnInfoList(SearchCriteria searchCriteria) {
        if (null == searchCriteria || StringUtils.isBlank(searchCriteria.getStatus()) || StringUtils.isBlank(searchCriteria.getCourtUid())) {
            return ResultResponse.failed(ResultCode.PARAMETER_NULL);
        }
        if (searchCriteria.getPage() < 1 || searchCriteria.getPageSize() < 1) {
            return ResultResponse.failed(ResultCode.PARAMETER_NULL);
        }
        Map<String, Object> restMap = warnInfoService.selectWarnInfoList(searchCriteria);
        return ResultResponse.success(restMap);
    }
}
